home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3.iso / chapte25 / ex11.c < prev    next >
C/C++ Source or Header  |  1995-06-04  |  1KB  |  31 lines

  1. #include <genstub.c>
  2.  
  3. // Windows message procedure.
  4. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  5. {
  6.     switch (uMsg)
  7.     {
  8.             case WM_COMMAND:       // Process menu items.
  9.                     switch ( LOWORD( wParam )  )
  10.                     {
  11.                         case IDM_TEST: // Allocate space for message.
  12.                            {
  13.                               LPVOID lpText = HeapAlloc( GetProcessHeap(), 0, 32 );
  14.                               wsprintf( lpText, "The heap address is %lX", lpText );
  15.                               MessageBox( hWnd, lpText, "GetProcessHeap()", MB_OK );
  16.                               HeapFree( GetProcessHeap( ), 0, lpText );
  17.                            }
  18.                         break;
  19.                         case IDM_EXIT:
  20.                               DestroyWindow( hWnd );
  21.                               break;
  22.                     }
  23.             break;
  24.             case WM_DESTROY:
  25.                     PostQuitMessage( 0 );
  26.                     break;
  27.             default:
  28.                  return DefWindowProc( hWnd, uMsg, wParam, lParam );
  29.     }
  30.     return NULL;
  31. }